package com.xiaobai.netease_news.activities;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;

import com.xiaobai.netease_news.R;
import com.xiaobai.netease_news.views.CircleProgressBar;

public class HeadLineActivity extends Activity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_head_line);

        ImageView closeBack = (ImageView) findViewById(R.id.close_and_back);
        closeBack.setOnClickListener(this);

        final CircleProgressBar progressBar = (CircleProgressBar) findViewById(R.id.head_line_progress);
        progressBar.setMax(100);
        progressBar.setVisibility(View.VISIBLE);

        WebView headLineWeb = (WebView) findViewById(R.id.head_line_web);
        headLineWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress >= 100)
                    progressBar.setVisibility(View.GONE);
            }
        });
        WebSettings settings = headLineWeb.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        headLineWeb.loadUrl("http://c.3g.163.com/nc/qa/headline/index.html");
    }

    @Override
    public void onClick(View v) {
        this.finish();
    }
}
